<%--
~ Copyright 2009-2015 by WWW.KNET.CN  All rights reserved.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<html>
<head>
    <title>客户特点列表</title>
    <meta name="decorator" content="default"/>
    <link rel="stylesheet" href="${ctxStatic}/bootstrap-table/bootstrap-table.css">
    <script src="${ctxStatic}/bootstrap-table/bootstrap-table.js"></script>
    <script src="${ctxStatic}/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
    <script src="${ctxStatic}/bootstrap-table/config.js"></script>
</head>
<body>
<ul class="nav nav-tabs">
    <!--默认不跳转-->
    <li class="active"><a href="javascript:void(0);">客户特点列表</a></li>
    <shiro:hasPermission name="sys:customerFeature:edit">
        <li><a href="${ctx}/sys/customerFeature/form">客户特点添加</a></li>
    </shiro:hasPermission>
</ul>

<form id="searchForm" action="${ctx}/sys/customerFeature/listAjaxData" method="post" class="breadcrumb form-search">
    <ul class="ul-form">
        <ul class="ul-form">
            <li>
                <div class="input-prepend">
                    <span class="add-on">名称</span>
                    <input name="name" type="text" class="input-medium" placeholder="请输入客户特点名称"/>
                </div>
                <%--<div class="input-prepend">
                    <span class="add-on">查询(小)</span>
                    <input name="productTypeValue" type="text" class="input-small" placeholder="s2"/>
                </div>--%>
            </li>
            <li class="btns">
                <button id="search" class="btn btn-small btn-primary" type="button">
                    查询<span class="icon-search icon-white"></span>
                </button>
            </li>
            <li class="clearfix"></li>
        </ul>
    </ul>
</form>

<table id="contentBootStrap" data-url="${ctx}/sys/customerFeature/listAjaxData">
    <thead>
    <tr>
        <th data-field="state" data-formatter="indexFormatter" data-align="center">序号</th>
        <th data-field="name" data-sortable="true" data-align="center">名称</th>
        <th data-field="dateCreated" data-sortable="true" data-align="center">创建时间</th>
        <th data-field="lastUpdated" data-sortable="true" data-align="center">修改时间</th>
        <th data-field="operate" data-align="left" data-formatter="operateFormatter" data-events="operateEvents">操作</th>
    </tr>
    </thead>
</table>
<script type="text/javascript">
    $(document).ready(function () {
        closeTip();
        $("#contentBootStrap").bootstrapTable(
                $.fn.BTConfigSimple({
                    pageList: [30, 50, 100],
                    pageSize: 30,
                    sortName: "name",
                    userQuery:function(){
                        return $('#searchForm').refreshByForm().query;
                    }
                }));
        $("#search").click(function () {
            refresh();
        });
    });

    function refresh(){
        $("#contentBootStrap").bootstrapTable(
                'refresh', $("#searchForm").refreshByForm());
    }

    function indexFormatter(value, row, index){
        return index+1;
    }

    function operateFormatter(value, row, index) {
        var array = [];
        array.push('<a class="edit" href="${ctx}/sys/customerFeature/form?id='+row.id+'" title="编辑/查看">');
        array.push('<i class="icon icon-edit"></i>');
        array.push('</a>');
        <shiro:hasPermission name="sys:customerFeature:edit">
            array.push('  ');
            array.push('<a class="remove" href="javascript:void(0)" title="删除">');
            array.push('<i class="icon icon-remove"></i>');
            array.push('</a>');
        </shiro:hasPermission>
        return array.join('');
    }

    var operateEvents = {
        'click .remove': function (e, value, row, index) {
            confirmx("您确认要删除记录[" + row.name + "]?",
                 function () {
                     $.ajax({
                            url: "${ctx}/sys/customerFeature/delete",
                            type: "post",
                            data: {id: row.id},
                            dataType: "json",
                            success: function (data) {
                                if (data.state == true) {
                                    showTip(data.message);
                                    refresh();
                                } else {
                                    alertx(data.message);
                                }
                            },
                            error: function (data, state, error) {
                                alertx(data.responseText, null, '请求错误');
                            }
                        });
                 });
        }
    };
</script>

</body>
</html>